import { MyAddressList } from "../components/address-list/address-list";
import {MyTrigger} from "../components/trigger/radio";
import { CouponsSelect } from '../components/coupon-select/coupons-select'

let payMethodsMix = {
  data() {
    return {
      payMethod: '1'
    }
  },
  methods: {
    oncheck(v) {
      this.payMethod = v
    }
  }
}

let isConfirmMix = {
  data() {
    return {
      isConfirm: false
    }
  },
  methods: {
    handleIsConfirm() {
      this.isConfirm =!this.isConfirm
    }
  }
}

let addressListMix = {
  data() {
    return {
      items: [
        {
          is_default: true
        },
        {
          is_default: false
        },
        {
          is_default: false
        }
      ]
    }
  },
  methods: {
    addAddress() {
      document.dispatchEvent(new CustomEvent('on-address-add', {
        detail: {}
      }))
    },
  }
}

let addressFormApp = {
  name: 'address-form-app',
  template: '#' + 'address-form-app-tpl',
  components: {
    [MyAddressList.tagName]: MyAddressList,
    [MyTrigger.tagName]: MyTrigger,
    [CouponsSelect.name]: CouponsSelect,
  },
  mixins: [
    payMethodsMix,
    isConfirmMix,
    addressListMix,
  ],
  data() {
    return {
      isOpenAction: false
    }
  }
}

window.initAddressFormApp = (el, template) => {
  new Vue({
    el,
    template,
    components: {
      [addressFormApp.name]: addressFormApp,
    },
    mounted() {
    },
    methods: {
    }
  })
}


